<?php

include_once  "function_xml_basic.php";

function GetXmlDns()
{
	$query_string = "/MINI/NETWORK/DNSS/DNS";
	$ret_array = GetAllValueToArray($query_string);
	return $ret_array;
}

function SetXmlDns($dns1, $dns2)
{	
	$query_string = "/MINI/NETWORK/DNSS/DNS";
	DeleteNode($query_string, NULL);

	$query_string = "/MINI/NETWORK/DNSS[last()]";
	if (trim($dns1) != "")
		AppendNode($query_string, "DNS", $dns1);
	
	if (trim($dns2) != "")
		AppendNode($query_string, "DNS", $dns2);
	
	ApplySysDns();
}


function ApplySysDns()
{
	$fp = fopen("/etc/resolv.conf", "w+");
	$ret_array = GetXmlDns();
	
	for ($i = 0; $i < count($ret_array); $i ++)
	{
		$write_string = $write_string. "nameserver ". $ret_array[$i]. "\n";
	}
	if (fwrite($fp, $write_string) == FALSE) 
	{
		return FALSE;
	}
	else
	{
		return TRUE;
	}
}

?>
